package com.sdx.console.crm.service;

import com.ibeetl.admin.core.service.BaseService;
import com.ibeetl.admin.core.util.PlatformException;
import com.sdx.console.crm.dao.CrmRepresentiveConfigDao;
import com.sdx.console.crm.entity.CrmRepresentiveConfig;
import org.beetl.sql.core.engine.PageQuery;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * 客服设置 Service
 */

@Service
@Transactional
public class CrmRepresentiveConfigService extends BaseService<CrmRepresentiveConfig>{

    @Resource
	private CrmRepresentiveConfigDao crmRepresentiveConfigDao;

    public PageQuery<CrmRepresentiveConfig>queryByCondition(PageQuery query){
        PageQuery ret =  crmRepresentiveConfigDao.queryByCondition(query);
        queryListAfter(ret.getList());
        return ret;
    }

    public void batchDelCrmRepresentiveConfig(List<String> ids){
        try {
            crmRepresentiveConfigDao.batchDelCrmRepresentiveConfigByIds(ids);
        } catch (Exception e) {
            throw new PlatformException("批量删除客服设置失败", e);
        }
    }

	public List<CrmRepresentiveConfig> all() {
		return crmRepresentiveConfigDao.all();
		}

	public CrmRepresentiveConfig getConfig() {
    	return crmRepresentiveConfigDao.single(1);

	}
}